package game.leon.seawar.vo;

import java.io.IOException;

/**
 * User: bianpeng
 * Date: 11-12-29
 * 简单封装了一下
 */
public class RemoteMessage {
    private int stamp;
    private int vid;
    private BaseVO vo;
    // unpack
    public RemoteMessage(BaseVO vo) {
        this.vo = vo;
    }
    // pack
    public RemoteMessage(int stamp, BaseVO vo) {
        this.stamp = stamp;
        this.vo = vo;
        this.vid = vo.vid();
    }
    public void pack(ByteBuffer byteBuffer) throws IOException {
        byteBuffer.write_short(stamp);
        byteBuffer.write_short(vid);
        vo.pack(byteBuffer);
    }
    public void unpack(ByteBuffer byteBuffer) throws IOException {
        stamp = byteBuffer.read_short();
        vid = byteBuffer.read_short();
        assert vid == vo.vid();
        vo.unpack(byteBuffer);
    }
    public BaseVO getVo() {
        return vo;
    }
    public int getVid() {
        return vid;
    }
    public int getStamp() {
        return stamp;
    }
}
